package com.suineg.pms.web.base;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suineg.pms.entity.base.Community;
import com.suineg.pms.service.base.CommunityService;

/**
 *
 *@author Suine
 */
@Controller
@RequestMapping(value = "/base/community")
public class CommunityController {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	private CommunityService communityService;

	@RequestMapping(value = "")
	public String defaut(){
		return "base/community";
	}
	
	@ResponseBody
	@RequestMapping(value = "checkName")
	public String checeName(@RequestParam("name") String name){
		if(name == null || name.isEmpty()){
			return "false";
		}
		Community community = communityService.findByName(name);
		if(community == null){
			return "true";
		}
		return "false";
	}
	
	
	@Autowired
	public void setCommunityService(CommunityService communityService) {
		this.communityService = communityService;
	}
	
}

